<% if session[:user_id] %>	
	<h1>Memorias disponibles</h1>

	<table border=1>
		<tr>
		  <th>Título</th>
		  <th>Descripción</th>
		  <th>Tipo de memoria</th>
		  <th>Capacidad (MB)</th>
		  <th>Velocidad (MHz)</th>
		  <th>URL</th>
		  <th>Precio</th>
		  <th></th>
		  <th></th>
		  <th></th>
		</tr>

	<% @memories.each do |memory| %>
		<tr>
		  <td><%= memory.title %></td>
		  <td><%= memory.description %></td>
    <td class="center"><%= memory.typemem %></td>
    <td class="center"><%= memory.capacity %></td>
    <td class="center"><%= memory.speed %></td>
		  <td><%= link_to memory.product_url, memory.product_url, :target => '_blank' %></td>
    <td class="center"><%= memory.price %></td>
		  
		  <td><%= link_to 'Mostrar', memory %></td>
		  <td><%= link_to 'Editar', edit_memory_path(memory) %></td>
		  <td><%= link_to 'Eliminar', memory, method: :delete, data: { confirm: '¿Está seguro?' } %></td>
		</tr>
	<% end %>
	</table>

	<br />

	<%= link_to 'Nueva memoria', new_memory_path %>
<% else %>
	<% if notice %>
	<p id="notice"><%= notice %></p>
	<% end %>

	<h1>Catalogo de memorias</h1>

	<% @memories.each do |memory| %>
		<div class="entry">
			<h3><%= memory.title %></h3>
			<%= sanitize(memory.description) %>
			<div class="price_line">
				<span class="price"><%= number_to_currency(memory.price) %></span>
				<% prod = Product.find(:first, :conditions => ["heir_id = ? and heir_type = ?",memory.id, 'Memory']) %>
				<%= button_to 'Añadir a la configuracion', line_products_path(product_id: prod.id) %>
			</div>
		</div>
	<% end %>
<% end %>
